import axios from "axios";
import http from "@/api/http.js";
const baseUrl = "http://localhost:8091";
const materialProductsRequest={
    // 分页查询
    loadMaterialProducts(materialProduct,page=1,limit=10,callBack){
        let url = baseUrl + "/material/selectAll?page=" + page + "&limit=" + limit;
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     新增物料产品信息
    loadAddMaterialProducts(materialProduct,callBack){
        let url = baseUrl + "/material/add";
        axios.post(url,materialProduct,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//    根据id查询物料产品信息
    loadSelectMaterialProductById(materialProductId,callBack){
        let url = baseUrl + "/material/selectById?materialProductId=" + materialProductId;
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     根据id修改物料产品信息
    loadUpdateMaterialProduct(materialProduct,callBack){
        let url = baseUrl + "/material/update";
        axios.post(url,materialProduct,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     根据id删除物料产品信息
    loadDeleteMaterialProductById(materialProductId,callBack){
        let url = baseUrl + "/material/delete?materialProductId=" + materialProductId;
        axios.delete(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    }
}
export default materialProductsRequest;